import java.util.Scanner;
public class TAM {
    public static void main(String[] args) {
        //数据类型  变量名 = 变量值;
        double banlance = 0;//余额
        boolean flag = true;
        Scanner scn = new Scanner(System.in);
        while(flag){
            System.out.println("=========ATM========");
            System.out.println(" 1、存款");
            System.out.println(" 2、取款");
            System.out.println(" 3、显示余额");
            System.out.println(" 4、退出");
            System.out.println("请选择(1-4)：");

            //System.out.println("您选择的是-->" + res);
            int res = scn.nextInt();//
            if(res == 1){
                //存款逻辑
                System.out.println("请输入存款的金额");
                double price = scn.nextDouble();//用户录入的金额
                banlance = banlance + price;
            }else if(res == 2){
                //取款逻辑
                System.out.println("请输入取款的金额");
                double price2 = scn.nextDouble();//用户录入的金额
                if(price2 > banlance){//取款金额 大于 余额
                    System.out.println("金额不足");
                }else if(price2 <= 0){
                    System.out.println("输入金额有误");
                }else{
                    banlance = banlance - price2;
                }
            }else if(res == 3){
                //显示余额
                System.out.println("金额为----->" + banlance);
            }else if(res == 4){
                //退出程序
                flag = false;
                //break;
            }else{
                //输入有误
                System.out.println("请选择正确的操作选项");
            }
        }
        //资源关闭
        scn.close();
    }
}
